﻿// Write a program that replaces in a HTML document given as string 
// all the tags <a href="…">…</a> with corresponding tags [URL=…]…/URL]. 

using System;
using System.Text.RegularExpressions;

public class ReplaceATagWithURL
{
    public static void Main()
    {
        string inputHTML = "<p>Please visit <a href=\"http://academy.telerik.com\">our site</a> to choose a training course. Also visit <a href=\"www.devbg.org\">our forum</a> to discuss the courses.</p>";

        string findForPattern = "<a href=\"(.*?)\">(.*?)</a>";
        string replaceWithPattern = "[URL=$1]$2[/URL]";
        string formatedHTML = Regex.Replace(inputHTML, findForPattern, replaceWithPattern);

        Console.WriteLine(formatedHTML);
    }
}